Skip to content

[HTTP/2] Functional Test cases#2367

Merged
DarshitChanpura merged 1 commit intoopensearch-project:mainfrom
reta:issue-2125
Dec 31, 2022
Merged

[HTTP/2] Functional Test cases#2367
DarshitChanpura merged 1 commit intoopensearch-project:mainfrom
reta:issue-2125

Conversation

@reta
Copy link
Collaborator

@reta reta commented Dec 22, 2022

Description

Add functional test cases for HTTP/2

Issues Resolved

Closes #2125

Testing

Added new test cases

Check List

  • New functionality includes testing
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@reta reta force-pushed the issue-2125 branch 6 times, most recently from d3a8988 to e248c6e Compare December 22, 2022 20:00
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
@codecov-commenter
Copy link

Codecov Report

Merging #2367 (24074c2) into main (1702d52) will decrease coverage by 0.04%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##               main    #2367      +/-   ##
============================================
- Coverage     61.09%   61.04%   -0.05%     
+ Complexity     3271     3267       -4     
============================================
  Files           260      260              
  Lines         18363    18362       -1     
  Branches       3250     3250              
============================================
- Hits          11219    11210       -9     
- Misses         5559     5563       +4     
- Partials       1585     1589       +4     
Impacted Files Coverage Δ
...urity/ssl/transport/SecuritySSLNettyTransport.java 62.36% <0.00%> (-4.31%) ⬇️
...earch/security/ssl/util/SSLConnectionTestUtil.java 93.18% <0.00%> (-2.28%) ⬇️
.../dlic/auth/ldap2/LDAPConnectionFactoryFactory.java 57.46% <0.00%> (-1.50%) ⬇️
...ecurity/ssl/rest/SecuritySSLReloadCertsAction.java 84.78% <0.00%> (-0.33%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@reta reta marked this pull request as ready for review December 22, 2022 23:28
@reta reta requested a review from a team December 22, 2022 23:28
@reta
Copy link
Collaborator Author

reta commented Dec 22, 2022

@peternied I have added a few new tests cases but the major change is to move the test client to Apache Async HttpClient 5 (which supports HTTP/2) and asserting that all communication happens using HTTP/2 protocol when HTTPS/SSL is on [1], thank you.

[1] https://github.com/opensearch-project/security/pull/2367/files#diff-8a5f07d4e22f127c17298eeebe6ea7bb6b49dd7b2ebd14398b7298627d8ed6d7R154

Assert.assertFalse(ccs.getBody().contains("AnotherSecredField"));
Assert.assertFalse(ccs.getBody().contains("xxx1")); Assert.assertEquals(ccs.getHeaders().toString(), 1, ccs.getHeaders().size());
Assert.assertFalse(ccs.getBody().contains("xxx1"));
Assert.assertEquals(ccs.getHeaders().toString(), 2, ccs.getHeaders().size());
Copy link
Collaborator Author

@reta reta Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 2 headers now: content type and content length

return new SecureRestClientBuilder(settings, configPath).setSocketTimeout(60000).build();
return new SecureRestClientBuilder(settings, configPath)
.setSocketTimeout(60000)
.setConnectionRequestTimeout(180000)
Copy link
Collaborator Author

@reta reta Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed by opensearch-project/common-utils#287 but needs manual setting now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we wait until that issue has been published? or we can create a tracker issue that reverts this change once common-utils publishes an artifact with that change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No action is needed: this change is good, it may just be redundant after opensearch-project/common-utils#287 but keeping it is fine, thanks.

Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @reta! I have a couple of questions, but this change this good to me.

final RequestConfig.Builder requestConfigBuilder = RequestConfig.custom()
.setResponseTimeout(Timeout.ofSeconds(60));

return hcb.setDefaultRequestConfig(requestConfigBuilder.build()).disableAutomaticRetries().build();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was disableAutomaticRetries() added because of issues with any test?

Leaving a link to the Default class in HttpComponents-client5 to come back to later to see the list of default non-retriable and retriable codes: https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.html

Create the HTTP request retry strategy with a max retry count of 1, default retry interval of 1 second, and using the following list of non-retriable I/O exception classes:
InterruptedIOException UnknownHostException ConnectException ConnectionClosedException SSLException and retriable HTTP status codes:
SC_TOO_MANY_REQUESTS (429) SC_SERVICE_UNAVAILABLE (503)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was disableAutomaticRetries() added because of issues with any test?

Leaving a link to the Default class in HttpComponents-client5 to come back to later to see the list of default non-retriable and retriable codes: https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryStrategy.html

Create the HTTP request retry strategy with a max retry count of 1, default retry interval of 1 second, and using the following list of non-retriable I/O exception classes:
InterruptedIOException UnknownHostException ConnectException ConnectionClosedException SSLException and retriable HTTP status codes:
SC_TOO_MANY_REQUESTS (429) SC_SERVICE_UNAVAILABLE (503)

Not really in the security plugin tests, but it is not needed (enabling retries won't harm here)

}


@Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, is there a way for a cluster admin to force HTTP/1? Would that ever be valid or desired as a config setting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm ... this is a good question, I don't see why one would do that intentionally, but the RestClientBuilder could force HTTP/1.1, see please [1] fe

[1] https://github.com/opensearch-project/security/pull/2367/files#diff-25d921c48bb0ef8fb56806d0d9cbed23e72f8e9b275a9ec606bc6be78cecb37eR192

@DarshitChanpura DarshitChanpura merged commit 17c2ba1 into opensearch-project:main Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HTTP/2] Functional Test cases

4 participants